<template>
  <div>
    <div>
      <router-link to="/list">unitList</router-link>
      <br>
      单元名称<input type="text" v-model="inputName">
      <button @click="addUnit">新增单元</button>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      inputName: ''
    }
  },
  methods: {
    addUnit () {
      this.$http({
        url: 'http://localhost:3000/units/addUnit',
        method: 'post',
        data: {name: this.inputName}
      }).then(
        res => {
          console.log(res)
        }
      ).catch(
        err => {
          console.log(err)
        }
      )
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
